Goto

Collaborating Authors

 count letter


Can ChatGPT Learn to Count Letters?

Conde, Javier, Martínez, Gonzalo, Reviriego, Pedro, Gao, Zhen, Liu, Shanshan, Lombardi, Fabrizio

arXiv.org Artificial Intelligence

In this paper we explore if ChatGPT can learn to count letters. Since the introduction of ChatGPT two years ago, Large Language Model (LLM) based tools have shown impressive capabilities to solve mathematical problems or to answer questions on almost any topic [1]. In fact, evaluation benchmarks have to be revised frequently to make then harder as LLM performance improves continuously [2]. The development of LLMs has also been hectic with new models presented by large companies such as Google with Gemini or Gemma, Meta with Llama or x.AI with Grok. OpenAI has also released newer versions and improvements of their Generative Pre-trained Transformer (GPT) family such as GPT4 [3] and its variants GPT4o and GPT4o1. Those foundational models are then adapted to answer questions or interact with users and complemented with other functionalities to implement conversational tools like ChatGPT. Despite these astonishing results, there are some simple tasks that LLMs struggle with, for example arithmetic operations [4] or even counting the occurrences of a given letter in a word. For example, many LLMs failed to count the number of "r" in strawberry


Why Do Large Language Models (LLMs) Struggle to Count Letters?

Fu, Tairan, Ferrando, Raquel, Conde, Javier, Arriaga, Carlos, Reviriego, Pedro

arXiv.org Artificial Intelligence

Large Language Models (LLMs) have achieved unprecedented performance on many complex tasks, being able, for example, to answer questions on almost any topic. However, they struggle with other simple tasks, such as counting the occurrences of letters in a word, as illustrated by the inability of many LLMs to count the number of "r" letters in "strawberry". Several works have studied this problem and linked it to the tokenization used by LLMs, to the intrinsic limitations of the attention mechanism, or to the lack of character-level training data. In this paper, we conduct an experimental study to evaluate the relations between the LLM errors when counting letters with 1) the frequency of the word and its components in the training dataset and 2) the complexity of the counting operation. We present a comprehensive analysis of the errors of LLMs when counting letter occurrences by evaluating a representative group of models over a large number of words. The results show a number of consistent trends in the models evaluated: 1) models are capable of recognizing the letters but not counting them; 2) the frequency of the word and tokens in the word does not have a significant impact on the LLM errors; 3) there is a positive correlation of letter frequency with errors, more frequent letters tend to have more counting errors, 4) the errors show a strong correlation with the number of letters or tokens in a word and 5) the strongest correlation occurs with the number of letters with counts larger than one, with most models being unable to correctly count words in which letters appear more than twice.